//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Menus.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
#include "Borland\\canlib.h"
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <mmsystem.h>
#include <math.h>
//---------------------------------------------------------------------------
struct TWMCanLib
{
    Cardinal Msg;
    DWORD hnd;
    WORD event;
    WORD _pad;
    Longint Result;
};

typedef struct
{
   unsigned int id;
   unsigned int dlc;
   unsigned char data[8];
}CanMessage;

DWORD Handle1;
UINT g_TIMEID;
char variantCode[60];
char canConfig[80];
UINT variantCounter;
UINT canConfigCounter;
UINT flowControlLength;
UINT flowControlRest;
int i, j;

bool flagStratDiag = false;
bool flagStrat03Mode = false;
bool flagSecAccess = false;
bool flagReset = false;
bool flagStartRoutine = false;
bool flagStopRoutine = false;
bool flagRoutineResult = false;
bool flagStatusRead = false;
bool flagReadDTC = false;
bool flagSurported = false;
bool flagClearDTC = false;
bool flagReadConfig = false;
bool flagWriteConfig = false;
bool flagWriteConfig1 = false;
bool flagReadViriantCode = false;
bool flagWriteViriantCode = false;
bool flagCtrlON = false;
bool flagCtrlOFF = false;
bool flagReturnECU = false;
bool flagNeedConfig1 = false;
bool flagNeedCode1 = false;
bool flagWriteCode1 = false;
bool flagCommControl = false;
bool flagDTCSetting = false;
bool flagInFlowControl = false;
//need add to clearFlag()

//---------------------------------------------------------------------------
void CALLBACK taskList(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2);
void __fastcall timerStart(UINT ms_time_val);
void task10ms(void);
void timerEnd(void);
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TMainMenu *MainMenu1;
        TMenuItem *More1;
        TMenuItem *CanMonitor1;
        TMenuItem *Help1;
        TMenuItem *About1;
        TGroupBox *GroupBox1;
        TButton *Button1;
        TComboBox *ComboBox1;
        TButton *Button2;
        TButton *Button3;
        TCheckBox *CheckBox1;
        TGroupBox *GroupBox2;
        TComboBox *ComboBox2;
        TButton *Button4;
        TButton *Button5;
        TButton *Button6;
        TGroupBox *GroupBox3;
        TButton *Button7;
        TComboBox *ComboBox3;
        TComboBox *ComboBox4;
        TGroupBox *GroupBox4;
        TButton *Button8;
        TButton *Button9;
        TButton *button10;
        TEdit *Edit1;
        TGroupBox *GroupBox5;
        TRadioButton *RadioButton1;
        TRadioButton *RadioButton2;
        TRadioButton *RadioButton3;
        TRadioButton *RadioButton4;
        TRadioButton *RadioButton5;
        TRadioButton *RadioButton6;
        TRadioButton *RadioButton7;
        TRadioButton *RadioButton8;
        TRadioButton *RadioButton12;
        TRadioButton *RadioButton13;
        TRadioButton *RadioButton14;
        TRadioButton *RadioButton15;
        TRadioButton *RadioButton27;
        TRadioButton *RadioButton17;
        TRadioButton *RadioButton18;
        TRadioButton *RadioButton19;
        TRadioButton *RadioButton20;
        TRadioButton *RadioButton21;
        TRadioButton *RadioButton22;
        TRadioButton *RadioButton23;
        TRadioButton *RadioButton24;
        TRadioButton *RadioButton28;
        TRadioButton *RadioButton9;
        TGroupBox *GroupBox6;
        TButton *Button11;
        TButton *Button12;
        TButton *Button13;
        TButton *Button14;
        TButton *Button15;
        TLabel *Label1;
        TPageControl *PageControl1;
        TTabSheet *TabSheet1;
        TTabSheet *TabSheet2;
        TComboBox *ComboBox5;
        TButton *Button16;
        TMemo *Memo1;
        TEdit *Edit2;
        TEdit *Edit10;
        TRadioButton *RadioButton10;
        TRadioButton *RadioButton11;
        TRadioButton *RadioButton16;
        TRadioButton *RadioButton25;
        TRadioButton *RadioButton26;
        TGroupBox *GroupBox7;
        TCheckBox *CheckBox2;
        TGroupBox *Groupbox8;
        TGroupBox *GroupBox9;
        TComboBox *ComboBox6;
        TComboBox *ComboBox7;
        TButton *Button17;
        TButton *Button18;
        TButton *Button19;
        TCheckBox *CheckBox3;
        TButton *Button20;
        TTimer *Timer1;
        TCheckBox *CheckBox4;
        TLabel *Label2;
        TComboBox *ComboBox8;
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall Button16Click(TObject *Sender);
        void __fastcall Button1Click(TObject *Sender);
        void __fastcall Button2Click(TObject *Sender);
        void __fastcall ComboBox3Change(TObject *Sender);
        void __fastcall ComboBox4Change(TObject *Sender);
        void __fastcall Button8Click(TObject *Sender);
        void __fastcall PageControl1Change(TObject *Sender);
        void __fastcall Button3Click(TObject *Sender);
        void __fastcall Button4Click(TObject *Sender);
        void __fastcall Button12Click(TObject *Sender);
        void __fastcall Button5Click(TObject *Sender);
        void __fastcall Button6Click(TObject *Sender);
        void __fastcall Button7Click(TObject *Sender);
        void __fastcall Button9Click(TObject *Sender);
        void __fastcall button10Click(TObject *Sender);
        void __fastcall Button11Click(TObject *Sender);
        void __fastcall RadioButton1Click(TObject *Sender);
        void __fastcall RadioButton2Click(TObject *Sender);
        void __fastcall RadioButton3Click(TObject *Sender);
        void __fastcall RadioButton4Click(TObject *Sender);
        void __fastcall RadioButton5Click(TObject *Sender);
        void __fastcall RadioButton6Click(TObject *Sender);
        void __fastcall RadioButton7Click(TObject *Sender);
        void __fastcall RadioButton8Click(TObject *Sender);
        void __fastcall RadioButton12Click(TObject *Sender);
        void __fastcall RadioButton13Click(TObject *Sender);
        void __fastcall RadioButton14Click(TObject *Sender);
        void __fastcall RadioButton15Click(TObject *Sender);
        void __fastcall RadioButton27Click(TObject *Sender);
        void __fastcall RadioButton17Click(TObject *Sender);
        void __fastcall RadioButton18Click(TObject *Sender);
        void __fastcall RadioButton19Click(TObject *Sender);
        void __fastcall RadioButton20Click(TObject *Sender);
        void __fastcall RadioButton21Click(TObject *Sender);
        void __fastcall RadioButton22Click(TObject *Sender);
        void __fastcall RadioButton23Click(TObject *Sender);
        void __fastcall RadioButton24Click(TObject *Sender);
        void __fastcall RadioButton28Click(TObject *Sender);
        void __fastcall RadioButton9Click(TObject *Sender);
        void __fastcall Button13Click(TObject *Sender);
        void __fastcall Button14Click(TObject *Sender);
        void __fastcall Button15Click(TObject *Sender);
        void __fastcall Button17Click(TObject *Sender);
        void __fastcall Button18Click(TObject *Sender);
        void __fastcall Button19Click(TObject *Sender);
        void __fastcall Button20Click(TObject *Sender);
        void __fastcall CheckBox2Click(TObject *Sender);
        void __fastcall Timer1Timer(TObject *Sender);
        void __fastcall CheckBox1Click(TObject *Sender);
        void __fastcall ComboBox2Change(TObject *Sender);
//---------------------------------------------------------------------------

private:	// User declarations
        void __fastcall messageTranceiver(TWMCanLib& Message);
        BEGIN_MESSAGE_MAP
            MESSAGE_HANDLER(WM__CANLIB/*17378*/, TWMCanLib, messageTranceiver); //WM_USER
        END_MESSAGE_MAP(TForm)
        void __fastcall clearFlag();
public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
//---------------------------------------------------------------------------
        void __fastcall memo1Display(CanMessage* messageTx, int flagRxTx);
        Word __fastcall calcKey(Word seed);
        void __fastcall sendList();
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
